import Vue from "vue";
import Router from "vue-router";
import store from "@/store";

Vue.use(Router);
import Layout from "@/layout";

export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true,
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true,
  },
  {
    path: "/monitors",
    // component: monitors,
    name: "大屏",
    hidden: true,
    component: () => import("@/views/monitors/index.vue"),
  },
  {
    path: "/",
    name: "数据大屏",
    component: () => import("@/views/index/index.vue"),
  },
  {
    path: "/flowing",
    component: Layout,
    children: [
      {
        path: "/flowing",
        name: "flowing",
        component: () => import("@/views/flowing/index.vue"),
        meta: { title: "账户流水", icon: "el-icon-coin" },
      },
    ],
  },
  {
    path: "/landing",
    component: Layout,
    children: [
      {
        path: "/landing",
        name: "landing",
        component: () => import("@/views/landing/index.vue"),
        meta: { title: "自定义落地页", icon: "el-icon-reading" },
      },
    ],
  },
  {
    path: "/advertisement",
    component: Layout,
    children: [
      {
        path: "/advertisement",
        name: "advertisement",
        component: () => import("@/views/advertisement/index.vue"),
        meta: { title: "广告计划", icon: "el-icon-date" },
      },
    ],
  },
  {
    path: "/tiktok",
    component: Layout,
    children: [
      {
        path: "/tiktok",
        name: "tiktok",
        component: () => import("@/views/tiktok/index.vue"),
        meta: { title: "抖音数据", icon: "el-icon-coordinate" },
      },
    ],
  },

  {
    path: "/age",
    component: Layout,
    children: [
      {
        path: "/age",
        name: "age",
        component: () => import("@/views/age/index.vue"),
        meta: { title: "年龄数据", icon: "el-icon-data-analysis" },
      },
    ],
  },
  {
    path: "/city",
    component: Layout,
    children: [
      {
        path: "/city",
        name: "city",
        component: () => import("@/views/city/index.vue"),
        meta: { title: "市级数据", icon: "el-icon-position" },
      },
    ],
  },
  {
    path: "/gender",
    component: Layout,
    children: [
      {
        path: "/gender",
        name: "gender",
        component: () => import("@/views/gender/index.vue"),
        meta: { title: "性别数据", icon: "el-icon-pie-chart" },
      },
    ],
  },
 
  {
    path: "/entrance",
    component: Layout,
    children: [
      {
        path: "/entrance",
        name: "entrance",
        component: () => import("@/views/entrance/index.vue"),
        meta: { title: "快捷入口", icon: "el-icon-guide" },
      },
    ],
  },
  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true },
];

const createRouter = () =>
  new Router({
    mode: "history", // require service support
    base: "/web/",
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  });
const router = createRouter();
//全局前置守卫
// router.beforeEach((to, from, next) => {
//     console.log(store.state.user)
// })
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
